<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<link rel="stylesheet" type="text/css" href="js/layui/css/layui.css"/>
	<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/layer/layer.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/layui/layui.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/Global.js"></script>
	<body>
		<div id="add-Stuent" style=";" >
		       <form class="layui-form" id="add-form" action="">
				       <div class="layui-form-item center" >
				    <label class="layui-form-label" style="width: 100px" >学生id</label>
				    <div class="layui-input-block">
				     <input type="text" disabled="disabled" name="name" id="studentid1" style="width: 240px" lay-verify="required" placeholder="请输入配置名称" autocomplete="off" class="layui-input">
				    </div>
				   </div>
				   
				   
		         <div class="layui-form-item center" >
		          <label class="layui-form-label" style="width: 100px" >学生编号</label>
		          <div class="layui-input-block">
		           <input type="text" disabled="disabled" name="name" id="studentno1" style="width: 240px" lay-verify="required" placeholder="请输入配置名称" autocomplete="off" class="layui-input">
		          </div>
		         </div>
		         <div class="layui-form-item">
		          <label class="layui-form-label" style="width: 100px">学生姓名</label>
		          <div class="layui-input-block">
		           <input type="text" name="type" id="studentname1" disabled="disabled" required style="width: 240px" lay-verify="required" placeholder="请输入配置类型" autocomplete="off" class="layui-input">
		          </div>
		         </div>
				 
	            <div class="layui-form-item">
	            <label class="layui-form-label">班级</label>
	           <div class="layui-input-block" style="width: 240px"">
	             <select name="city" lay-verify="required" id="testTYpe">
	               <option value="请选择"></option>
	              
	              
	             </select>
	           </div>
	           </div>
			    

			
			
		         <div class="layui-form-item">
		          <label class="layui-form-label" id="isDelete" style="width: 100px">是否删除 </label>
		          <div class="layui-input-block">
		           <input type="number" name="value" disabled="disabled" required style="width: 240px" lay-verify="required" placeholder="请输入配置值" autocomplete="off" id="studentDelete" class="layui-input">
		           <!-- <input type="hidden" name="id" style="width: 240px" autocomplete="off" class="layui-input"> -->
		          </div>
		         </div>
		         <div class="layui-form-item">
		          <div class="layui-input-block">
		          <input type="button" value="保存" id="studentSave1" class="layui-btn">
		        
		          </div>
		         </div> 
		       </form>  
		    </div>
	
	</body>
	
<script>//Demo
layui.use('form', function(){
  var form = layui.form;
  
  //监听提交
  form.on('submit(formDemo)', function(data){
    layer.msg(JSON.stringify(data.field));
    return true;
  });
});
</script>
<script type="text/javascript">
	$(function(){
		var newscript = document.createElement('script');
		newscript.setAttribute('type','text/javascript');
		newscript.setAttribute('src','js/Global.js');
		var head = document.getElementsByTagName('head')[0];
		head.appendChild(newscript);
		
		
		 	 var studentid=window.globalConfig.id;
			  
          $.ajax({
			   type:"get",
			    url:"http://127.0.0.1:8080/student/updateClass",
			    
			   contentType:"application/x-www-form-urlencoded;charset=utf-8",
			    
			  data: {'studentid':studentid},
			   success:function(msg){
				   $("#studentid1").val(msg.data.students[0].studentid);
				 $("#studentno1").val(msg.data.students[0].studentno);
				  $("#studentname1").val(msg.data.students[0].studentname)
				  $("#studentDelete").val(msg.data.students[0].isDelete)
				  var clazz=msg.data.clazzes;
			  /* console.log(msg.data.students[0].studentno) */
			       var optionstring = "";  
			     for(var key=1 in clazz ){
					 console.log(key+"  "+clazz[key].clazzno)
						  optionstring += "<option value=\""  +clazz[key].clazzno + "\">" + clazz[key].clazzno + "</option>"; 
                            $("#testTYpe").html("<option value='请选择'  >请选择...</option>"+ optionstring); 
						
				 }
				 
				 }
		  }) 
		 
		 
		     
		  $("#studentSave1").click(function(){
             var data={
            			 "studentid":$("#studentid1").val(),
            			  "studentno":$("#studentno1").val(),
            			  "studentname":$("#studentname1").val(),
            			  "clazzid":$("#testTYpe").val(),
            			  "isDelete":$("#studentDelete").val()
            }
			$.ajax({
				   type:"post",
				    dateType:"json",
				   contentType: "application/json;charset=utf-8",
				   url:"http://127.0.0.1:8080//student/updata",
				   data:JSON.stringify(data),
				   success:function(msg){
					   alert(msg.data)
				   },
				   error:function(){
					   alert("失败")
				   }
			})
			 
		
		  })
		
	})
	
</script>

</html>
